#
# scrap.py -- dead ships and debris
# 
# author: Tom "Knio" Flanagan
#         knio@h4xn3t.net
#         theknio@gmail.com
#         irc.freenode.net - Knio - #python #pygame #py
#
# this file released under Public Domain
#

from constants import *
import object

class Scrap(object.Object):
    sprite = 'images/scrap.bmp'
    def __init__(self, battle, **kwargs):
        object.Object.__init__(self, battle, **kwargs)
        self.hull = 800

    def hit(self, weapon, damage):
        if self.hull >= damage: self.hull -= damage; damge = 0
        if self.hull <= damage: damage -= self.hull; self.hull = 0
        if self.hull <= 0:
            self.die(damage)

    def die(self, damage):
        if not self.state: return
        n = int(damage/self.size*2)+1
        for i in range(n):
            Scrap(self.battle, size=math.sqrt(self.size**2/float(n)), **self.coordinates(CI*(i/float(n)),2*i).vector())
                
                
        
